#ifndef MESSAGE_HPP
#define MESSAGE_HPP

#include <iostream>
#include <string>

class Message {
public:
    Message(const std::string &s) : contents(s) { }
    // 友元函数，使用常量引用和内部的print方法
    friend std::ostream &operator<<(std::ostream &os, Message &msg) {
        return msg.print(os);
    }

private:
    // 实际输出函数，const修饰，保证不修改对象状态
    std::ostream &print(std::ostream &os) const;

private:
    std::string contents;
};

#endif